Repository navigation
fix(status): 补 TRANSFERRING(9) + 未知状态码退化 - #3
Merged
Merged
Conversation
官方状态码有 0..10(含 9 = TRANSFERRING),但 `ServerStatus` 枚举漏了 9。 后果不是"显示错一个值",而是: - WebSocket 的 `status` 消息 `data` 解码成 `Server` 时,枚举初始化失败 → 整条消息抛错 → 上层收不到这次状态更新(服务器启动/停止时的迁移阶段会卡住)。 实测(真实账号,HTTP 轮询与 WS 推送对照)确认服务器会依次经过 10 PREPARING → 6 LOADING → 2 STARTING → 1 ONLINE → 3 STOPPING → 5 SAVING → 0 OFFLINE, 其中迁移阶段的状态码就是 9。 改动: - `ServerStatus` 补 `case TRANSFERRING = 9`; - 新增 `case UNKNOWN = -1` 与宽容的 `init(from:)`:将来新增状态码时退化成 `.UNKNOWN`, 不再让整条 `Server` 解码失败; - 新增 `ServerStatusDecodingTests`:11 个官方取值逐一断言 + 未知码退化用例。 上层(OrzMCApp)需要相应把 `.UNKNOWN` 当成过渡态展示。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fix(status): 补上 TRANSFERRING(9) 并让未知状态码退化而不是整条消息解码失败
官方状态码有 0..10(含 9 = TRANSFERRING),但
ServerStatus枚举漏了 9。后果不是"显示错一个值",而是:
status消息data解码成Server时,枚举初始化失败 →整条消息抛错 → 上层收不到这次状态更新(服务器启动/停止时的迁移阶段会卡住)。
实测(真实账号,HTTP 轮询与 WS 推送对照)确认服务器会依次经过
10 PREPARING → 6 LOADING → 2 STARTING → 1 ONLINE → 3 STOPPING → 5 SAVING → 0 OFFLINE,
其中迁移阶段的状态码就是 9。
改动:
ServerStatus补case TRANSFERRING = 9;case UNKNOWN = -1与宽容的init(from:):将来新增状态码时退化成.UNKNOWN,不再让整条
Server解码失败;ServerStatusDecodingTests:11 个官方取值逐一断言 + 未知码退化用例。上层(OrzMCApp)需要相应把
.UNKNOWN当成过渡态展示。